#include "com.h"                                                           

int main()
{
    int fd = open(PATHNAME, O_WRONLY | O_RDONLY);//0

    if(fd < 0){                                         
        perror("open");                                          
        return 1;                                           
    }                                                      

    char msg[128];                                                        
    while(1){                                             
        msg[0] = 0;                                             
        printf("Please Enter# ");                              
        fflush(stdout);                                        
        ssize_t s = read(0, msg, sizeof(msg) - 1);                            
        if(s < 0){                                                       
            perror("read");
            return 1;                                         
        }
        else if(s == 0){
            printf("read file end\n");
            return 0;
        }
        else{
            sleep(1);
            msg[s - 1] = 0;                                                      
            write(fd, msg, strlen(msg));
        }
    }
    return 0;
}
